/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Thread;

import Interface.IMain;
import StaticClass.ArrSocket;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Oho
 */
public class Connection extends Thread {

    int port;

    public Connection(int port) {
        this.port = port;
    }

    @Override
    public void run() {
        try {
            ServerSocket sv;
            sv = new ServerSocket(port);
            while (true) {
                Socket sk = sv.accept();
                ArrSocket.sockList.add(sk);
                ArrSocket.ArrConnect.add(this);
                new ThreadChat(sk).start();
                
               // new ThreadMain(4567).start();//chat
               // new ThreadMain(7890).start();//send file
                // goi lai ham khoi tao jtable cua server
            //    ArrSocket.im = new IMain();
                ArrSocket.im.InitTable();
            }
        } catch (IOException ex) {
            Logger.getLogger(Connection.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
